package com.cter.thinkingInSpringBoot.dao;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Stream;

import org.springframework.stereotype.Component;

import com.cter.thinkingInSpringBoot.to.Post;

@Component
public class PostRepository {
	private Map<Long,Post> data = new HashMap<Long,Post>();
	
	private AtomicLong nextIdGenerator  = new AtomicLong(1L);
	
	public PostRepository() {
		Stream.of("post one","post two").forEach(title ->{
			Long id=this.nextId();
			data.put(id, Post.builder().id(id).title(title).content("你是"+id).build());
		});
	}
}
